<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
        <head>
                <meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
                <title></title>
                <link rel="stylesheet" href="__PUBLIC__/Css/bootstrap.min.css" />
                <link rel="stylesheet" href="__PUBLIC__/Css/common.css" />
                <jquery/>
                <script type="text/javascript" src='__PUBLIC__/Js/goods.js'></script>
                <script type="text/javascript">
                        $(function() {
                                //选择类型的时候触发的ajax
                                $('select[name=type_tid]').change(function() {
                                        $(this).find('option[value=0]').attr('disabled', 'disabled');
                                        var oVal = $(this).val();
                                        $.ajax({
                                                url: '__MODULE__' + '&m=Admin&c=TypeAttr&a=ajax_attr',
                                                data: {tid: oVal},
                                                dataType: 'json',
                                                type: 'post',
                                                success: function(data) {
                                                        if (data) {
                                                                $('#spec tr.info td').html('该类型下暂时没有添加商品规格或者您还没有选择类型！');
                                                                $('#attr tr.info td').html('该类型下暂时没有添加商品属性或者您还没有选择类型！')
                                                                $.each(data, function(k, v) {
                                                                        if (v.class == 1) {
                                                                                if ($('#spec tr.info td').html() == '该类型下暂时没有添加商品规格或者您还没有选择类型！') {
                                                                                        $('#spec tr.info td').html('');
                                                                                }
                                                                                oRadio = '<dl style="padding-left:10px;float:left;padding-bottom:10px;"><dt style="padding-left:10px;padding-bottom:10px;padding-top:10px;font-size:16px;">' + v.taname + '</dt>';
                                                                                var tempArr = new Array();
                                                                                tempArr = v.tavalue.split(',');
                                                                                for (i = 0; i < tempArr.length; i++) {
                                                                                        oRadio += '<dd style="float:left;width:300px;padding-right:15px;"><label style="float:left;"><input type="checkbox" class="standard" name="standard_' + v.taid + '[' + i + ']" style="float:left;margin-right:10px;" value="' + tempArr[i] + '">' + '<p style="float:right">' + tempArr[i] + '</p></label><input type="text" style="float:right;width:170px;" placeholder="附加价格,不需要可以不填" name="standard_' + v.taid + '_' + i + '_added"></dd>';
                                                                                }
                                                                                oRadio += '</dl>';
                                                                                $('#spec tr.info td').append(oRadio);
                                                                        }
                                                                        if (v.class == 0) {
                                                                                if ($('#attr tr.info td').html() == '该类型下暂时没有添加商品属性或者您还没有选择类型！') {
                                                                                        $('#attr tr.info td').html('');
                                                                                }
                                                                                oSelect = '<span style="line-height:40px;font-weight:700;font-size:14px;display:inline-block;width:100px;">' + v.taname + '：</span><select name="attr_' + v.taid + '" style="margin:10px;">';
                                                                                var tempArr2 = new Array();
                                                                                tempArr2 = v.tavalue.split(',');
                                                                                for (i = 0; i < tempArr2.length; i++) {
                                                                                        oSelect += '<option value="' + tempArr2[i] + '">' + tempArr2[i] + '</option>';
                                                                                }
                                                                                oSelect += '</select>&nbsp;附加价格 : &nbsp;<input type="text" placeholder="附加价格，不需要可以不填" style="margin:0px;" name="attr_' + v.taid + '_added"><br/>';
                                                                                $('#attr tr.info td').append(oSelect);
                                                                        }
                                                                })

                                                        }
                                                }
                                        })
                                        $.ajax({
                                                url: '__MODULE__' + '&m=Admin&c=Category&a=ajax_cate',
                                                data: {tid: oVal},
                                                dataType: 'json',
                                                type: 'post',
                                                success: function(data) {
                                                        var option = '';
                                                        if (data) {
                                                                $.each(data, function(k, v) {
                                                                        option += '<option value=' + v.cid + '>' + v._name + '</option>';
                                                                })
                                                        }
                                                        $('select[name=cid]').html('');
                                                        $('select[name=cid]').append(option);
                                                }
                                        })
                                        $.ajax({
                                                url: '__MODULE__' + '&m=Admin&c=Brand&a=ajax_brand',
                                                data: {tid: oVal},
                                                dataType: 'json',
                                                type: 'post',
                                                success: function(data) {
                                                        var option = '<option value="0">-----------请选择-----------</option>';
                                                        if (data) {
                                                                $.each(data, function(k, v) {
                                                                                option += '<option value=' + v.bid +'>' + v.bname + '</option>';     
                                                                })
                                                        }
                                                        $('select[name=bid]').html('');
                                                        $('select[name=bid]').append(option);
                                                }
                                        })
                                })
                        })
                </script>
        </head>
        <body>
                <div class="container-fluid">
                        <div class="row-fluid">
                                <div class="span12">
                                        <form action="" method='post'>
                                                <fieldset>
                                                        <legend>编辑商品</legend>
                                                        <table class='table table-bordered table-hover'>
                                                                <thead>
                                                                        <tr>
                                                                                <th colspan="2" class="btn btn-primary">基本信息</th>
                                                                        </tr>
                                                                </thead>
                                                                <tbody>
                                                                        <tr class="info">
                                                                                <td>所属类型</td>
                                                                                <td>
                                                                                        <select name="type_tid">
                                                                                                <option value="0">----------请选择----------</option>
                                                                                                <foreach from='$typeInfo' value='$v'>
                                                                                                        <option value="{$v.tid}" <if value="$v.tid==$goodsInfo.type_tid">selected="selected"</if>>{$v.tname}</option>
                                                                                                </foreach>
                                                                                        </select>
                                                                                        <span class='help-inline help'>----------注:所属类型,分类,品牌请先手动添加再选择----------</span>
                                                                                </td>
                                                                        </tr>
                                                                        <tr class="info">
                                                                                <td>所属分类</td>
                                                                                <td>
                                                                                        <select name="cid">
                                                                                                <option value="0">----------请选择-----------</option>
                                                                                                <foreach from="$cateInfo" value="$v">
                                                                                                        <option value="{$v.cid}"<if value="$v.cid eq $goodsInfo.category_cid">selected="selected"</if>>{$v.cname}</option>
                                                                                                </foreach>
                                                                                        </select>
                                                                                        <span class='help-inline help'>----------注:请先选择所属类型再选择所属分类----------</span>
                                                                                </td>
                                                                        </tr>
                                                                        <tr class="info">
                                                                                <td>所属品牌</td>
                                                                                <td>
                                                                                        <select name="bid">
                                                                                                <option value="0">----------请选择----------</option>
                                                                                                <foreach from='$brandInfo' value='$v'>
                                                                                                        <option value="{$v.bid}" <if value="$v.bid eq $goodsInfo['brand_bid']">selected="selected"</if>>{$v.bname}</option>
                                                                                                </foreach>
                                                                                        </select>
                                                                                </td>
                                                                        </tr>
                                                                        <tr class="info">
                                                                                <td>商品名称</td>
                                                                                <td>
                                                                                        <input type="text" name='gname' value="{$goodsInfo['gname']}"/>
                                                                                        <span class='help-inline help'>----------注:商品标题最多45个字符----------</span>
                                                                                </td>
                                                                        </tr>
                                                                        <tr class="info">
                                                                                <td>商品次标题</td>
                                                                                <td>
                                                                                        <input type="text" name='lhname' value="{$goodsInfo['hlname']}"/>
                                                                                </td>
                                                                        </tr>
                                                                        <tr class="info">
                                                                                <td>单位</td>
                                                                                <td>
                                                                                        <input type="text" name='unit' value='{$goodsInfo["unit"]}'/>
                                                                                </td>
                                                                        </tr>
                                                                        <tr class="info">
                                                                                <td>市价场</td>
                                                                                <td>
                                                                                        <input type="text" name='mprice' value='{$goodsInfo["mprice"]}'/>
                                                                                        <span class='help-inline help'>----------注:价格为敏感区域，请谨慎填写----------</span>
                                                                                </td>
                                                                        </tr>
                                                                        <tr class="info">
                                                                                <td>京东价</td>
                                                                                <td>
                                                                                        <input type="text" name='jdprice' value='{$goodsInfo["jdprice"]}'/>
                                                                                        <span class='help-inline help'>----------注:价格为敏感区域，请谨慎填写----------</span>
                                                                                </td>
                                                                        </tr>
                                                                        <tr class="info">
                                                                                <td>点击次数</td>
                                                                                <td>
                                                                                        <input type="text" name='click' value='{$goodsInfo["click"]}'/>
                                                                                </td>
                                                                        </tr>
                                                                        <tr class="info">
                                                                                <td>商品库存</td>
                                                                                <td>
                                                                                        <input type="text" name='stock' value='{$goodsInfo["stock"]}'/>
                                                                                </td>
                                                                        </tr>
                                                                </tbody>
                                                        </table>

                                                        <p class="btn btn-primary">商品属性</p>
                                                        <table class="table table-bordered table-hover" id='attr' class="info">
                                                                <tr class="info">
                                                                        <td>
                                                                                <foreach from="$attrList" value="$v">
                                                                                        <if value="$v">
                                                                                                <span style="line-height:40px;font-weight:700;font-size:14px;display:inline-block;width:100px;">{$v.taname}</span>
                                                                                                <select style="margin:10px;" name="attr_{$v.taid}">
                                                                                                        <foreach from="$v['tavalue']" value='$s'>
                                                                                                                <option value="{$s}"   <foreach from="$goodsAttr" value="$val"><if value="$val.ganame eq $s and $val.type_attr_taid eq $v.taid">selected="selected"</if></foreach>>{$s}</option>
                                                                                                        </foreach>
                                                                                                </select>
                                                                                                附加价格 :  <input type="text" name="attr_{$v.taid}_added" style="margin:0px;" placeholder="附加价格，不需要可以不填" value="<foreach from='$goodsAttr' value='$val'><if value='$val.type_attr_taid eq $v.taid'>{$val['added']}</if></foreach>"/><br/>
                                                                                                <else>
                                                                                                        该类型下暂时没有添加商品属性或者您还没有选择类型！    
                                                                                        </if>
                                                                                </foreach>
                                                                        </td>
                                                                </tr>
                                                        </table>
                                                        <p class="btn btn-primary">商品规格</p>
                                                        <table class="table table-bordered table-hover" id='spec'>
                                                                <tr class="info">
                                                                        <td>
                                                                                <foreach from="$standList" value="$v">
                                                                                        <if value="$v">
                                                                                                <dl style="padding-left:10px;float:left;padding-bottom:10px;">
                                                                                                        <dt style="padding-left:10px;padding-bottom:10px;padding-top:10px;font-size:16px;">{$v.taname}</dt>
                                                                                                        <foreach from='$v["tavalue"]' key="$k"value="$s" >
                                                                                                                <dd style="float:left;width:300px;padding-right:15px;">
                                                                                                                        <label style="float:left;">
                                                                                                                                <input type="checkbox" value="{$s}" style="float:left;margin-right:10px;" name="standard_{$v.taid}[{$k}]" class="standard"  <foreach from="$goodStand" value="$ns"><if value="$ns.type_attr_taid eq $v.taid and $ns.ganame eq $s">checked="checked"</if></foreach>  /> 
                                                                                                                                        <p style="float:right">{$s}</p>
                                                                                                                        </label>
                                                                                                                        <input type="text" name="standard_{$v.taid}_{$k}_added" placeholder="附加价格,不需要可以不填" style="float:right;width:170px;" <foreach from='$goodStand' value='$ns'><if value='$ns.type_attr_taid eq $v.taid and $ns.ganame eq $s'>value="{$ns['added']}"</if></foreach> />
                                                                                                                </dd>
                                                                                                        </foreach>
                                                                                                </dl>
                                                                                                <else>
                                                                                                        该类型下暂时没有添加商品规格或者您还没有选择类型！
                                                                                        </if>
                                                                                </foreach>
                                                                        </td>
                                                                </tr>
                                                        </table>

                                                        <table class='table table-bordered'>
                                                                <tr>
                                                                        <th colspan="2" class="btn btn-primary">列表图</th>
                                                                </tr>
                                                                <tr class="info">
                                                                        <td>上传图片</td>
                                                                        <td>
                                                                                <upload  name='listimg' alt="false" water="false" limit='1' waterbtn="false" dir="upload/listimg/" width="80" height="40" size="1" data='$listimg'/>
                                                                        </td>
                                                                </tr>
                                                        </table>

                                                        <table class='table table-bordered'>
                                                                <tr>
                                                                        <th colspan="2" class="btn btn-primary">商品图</th>
                                                                </tr>
                                                                <tr class="info">
                                                                        <td>上传图片</td>
                                                                        <td>
                                                                                <upload  name='thumb' alt="false" water="false" limit='10' waterbtn="false" dir="upload/goodimg/" width="80" height="50" size="1" data='$thumb'/>
                                                                        </td>
                                                                </tr>
                                                        </table>

                                                        <table class='table'>
                                                                <tr class="next_show">
                                                                        <th class="btn btn-primary">商品详细<i class='ico'></i></th>
                                                                </tr>
                                                                <tr class="info hide">
                                                                        <td>
                                                                                <ueditor name='detailCon' content='{$goodsdetail.detailCon}'/>
                                                                        </td>
                                                                </tr>
                                                        </table>

                                                        <table class='table'>
                                                                <tr class="next_show">
                                                                        <th class="btn btn-primary">售后服务<i class='ico'></i></th>
                                                                </tr>
                                                                <tr class="info hide">
                                                                        <td>
                                                                                <ueditor name='service' content='{$goodsdetail.service}'/>
                                                                        </td>
                                                                </tr>
                                                        </table><br/><br/><br/><br/>
                                                        <div class="fixed"><br/><input type="submit" value="确认修改" class="btn btn-success btn-large" /></div>
                                                </fieldset>
                                                <input type="hidden" name="gid"  value='{$hd.get.gid}'/>
                                        </form>
                                </div>
                        </div>
                </div>
        </body>
</html>